﻿using System;
using System.Linq;

using Supremacy.Text;

using SupremacyEditor.Text;

namespace SupremacyEditor
{
    public interface IGameDataModel
    {
        #region Properties and Indexers
        ITextDatabase TextDatabase { get; }
        ObservableKeyedCollection<string, IRacePresentationModel> Races { get; }
        #endregion
    }

    public class GameDataModel : IGameDataModel
    {
        private readonly ObservableKeyedCollection<string, IRacePresentationModel> _races;
        private readonly ITextDatabase _textDatabase;

        public GameDataModel()
        {
            _races = new ObservableKeyedCollection<string, IRacePresentationModel>(o => o.Key);
            _textDatabase = EditorTextDatabase.Load("vfs:///Resources/Data/TextDatabase.xml");
        }

        #region IGameDataModel Members
        public ITextDatabase TextDatabase
        {
            get { return _textDatabase; }
        }

        public ObservableKeyedCollection<string, IRacePresentationModel> Races
        {
            get { return _races; }
        }
        #endregion
    }
}